# -*- coding: UTF-8 -*-
# @Time : 2022/1/15 0015 13:32
# @Author : lyw
# @Remark :
import time

from mxsoftpy import Model
from pydantic import constr

from model.common.CRM.server_room import DeleteModel


def cabinet_fields(field):
    """机柜别名模型"""
    fields_dict = {
        'name': 'cabinet_name',
        'parent': "sroom_parent",
        'desc': 'cabinet_desc'
    }
    return fields_dict.get(field) or field


class CabinetModel(DeleteModel):
    """机柜新建"""
    name: constr(min_length=1, max_length=50)  # 机柜名称
    parent: str = ""  # 机柜所属的机房
    desc: constr(max_length=300) = ""  # 机房备注
    update_time: int = int(time.time())
    binding_sd: int = 0
    binding_sd_space: int = 0
    total_space: int

    class Config:
        alias_generator = cabinet_fields


class CabinetUpdateModel(Model):
    """机柜修改模型"""
    name: constr(min_length=1, max_length=50) = None  # 机柜名称
    parent: str = None  # 机柜所属的机房
    desc: constr(max_length=300) = None  # 机房备注

    # total_space: int = 1

    class Config:
        alias_generator = cabinet_fields
